import pandas as pd

from openpyxl import Workbook
from openpyxl.reader.excel import load_workbook

# 创建工作簿写数据
wb = Workbook()
ws = wb.active
ws['A1'] = '小虎'
ws.append([11, 22, 33, 44])
ws.title = '我是ws'

# 在末尾插入（默认）
ws1 = wb.create_sheet("Mysheet1")
ws1.title = '我是ws1'
# 插入第一个位置
ws2 = wb.create_sheet("Mysheet2", 0)
ws2.title = '我是ws2'
# 倒数第二个位置插入
ws3 = wb.create_sheet("Mysheet3", -1)
ws3.title = '我是ws3'
wb.save('data/test1.xlsx')

# 读取工作簿数据
wb = load_workbook('data/学生综合信息.xlsx')
ws = wb['学生基本信息表']
rows_list = list(ws.rows)
info_list = []
for rows in rows_list:
    info = []
    for cell in rows:
        info.append(cell.value)
    info_list.append(info)
    print('-------------------')

df1 = pd.DataFrame(info_list)
print(df1)
